import axios from "@/api/http.js";

export const axiosRequest = (type, url, object) => {
  let params = "";
  if (type === "get") {
    //  遍历对象拼接参数
    for (const key in object) {
      params += `&${key}=${object[key]}`;
    }
    //  将第一个参数的&字符改为?
    if (params) {
      params = `?${params.substring(1)}`;
    }
    return axios.get(url + params);
  }
  if (type === "post") return axios.post(url, object);
  if (type === "delete") return axios.delete(url, { data: object });
};
